package com.mdd.admin.controller;

import com.mdd.admin.service.IWxCustomerProductService;
import com.mdd.admin.validate.WxCustomerCreateValidate;
import com.mdd.admin.validate.WxCustomerSearchValidate;
import com.mdd.admin.validate.WxCustomerUpdateValidate;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.vo.WxCustomerVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/wxcustomer")
@Api(tags = "企业微信客服管理")
public class WxCustomerProductController {

    @Resource
    IWxCustomerProductService iWxCustomerService;

    @GetMapping("/list")
    @ApiOperation(value="企业微信客服列表")
    public AjaxResult<PageResult<WxCustomerVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated WxCustomerSearchValidate wxCustomerSearchValidate) {
        PageResult<WxCustomerVo> list = iWxCustomerService.list(pageValidate, wxCustomerSearchValidate);
        return AjaxResult.success(list);
    }

    @PostMapping("/add")
    @ApiOperation("企业微信客服新增")
    public AjaxResult<Object> add(@Validated @RequestBody WxCustomerCreateValidate wxCustomerCreateValidate) {
        iWxCustomerService.add(wxCustomerCreateValidate);
        return AjaxResult.success();
    }

    @PostMapping("/edit")
    @ApiOperation("企业微信客服修改")
    public AjaxResult<Object> edit(@Validated @RequestBody WxCustomerUpdateValidate updateValidate) {
        iWxCustomerService.edit(updateValidate);
        return AjaxResult.success();
    }

    @PostMapping("/del")
    @ApiOperation("商品删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iWxCustomerService.del(idValidate.getId());
        return AjaxResult.success();
    }
}
